package faf.web.data;

import org.springframework.validation.Errors;
import org.springframework.validation.Validator;

import faf.entities.Survey;

public class CreateSurveyFormValidateur implements Validator {

	@Override
	public boolean supports(Class arg0) {
		return Survey.class.equals(arg0);
	}

	@Override
	public void validate(Object command, Errors errors) {
			
		Survey form = (Survey) command;
		
		if(form.getTitle().length() == 0) {
			errors.rejectValue("title", "value-required");
		}
		if(form.getDescription().length() == 0) {
			errors.rejectValue("description", "value-required");
		}
	}

}
